package com.intellij.ide.license.idea;

import com.intellij.ide.license.LicenseMessages;
import com.intellij.ide.license.LicenseValidator;
import com.intellij.ide.license.impl.EvaluationLicense;
import com.intellij.ide.license.impl.LicenseFactoryImpl;
import com.intellij.ide.license.impl.LicenseFile;
import com.intellij.licensecommon.data.LicenseData;
import com.intellij.licensecommon.data.SubscriptionLicense;
import com.intellij.licensecommon.data.SubscriptionLicenseDataImpl;
import com.jetbrains.licenseServer.Products;

import java.util.Date;
import java.util.UUID;

class IdeaLicenseFactoryImpl extends LicenseFactoryImpl {

    public IdeaLicenseFactoryImpl(LicenseMessages licenseMessages) {
        super(licenseMessages);
    }

    public LicenseValidator createLicenseValidator() {
        return new IdeaLicenseValidator();
    }

    protected EvaluationLicense doCreateEvaluationLicense(long generationTime) {
        return new EvaluationLicense(new Date(generationTime), 13, m().isEAP() ? "EAP Member" : "IntelliJ IDEA Evaluator", getLicenseType(), 30);
    }

    @Override
    public int getProductVersion() {
        return 13;
    }

    @Override
    public String getValidatorVersion() {
        return IdeaLicenseValidator.VERSION;
    }

    public boolean k() {
        return true;
    }

    @Override
    public String getProductName() {
        return "idea";
    }

    @Override
    public int getLicenseType() {
        return 1;
    }

    @Override
    public LicenseFile e() {
        return IdeaLicense.create();
    }

    @Override
    public UUID getProductUUID() {
        return Products.IDEA;
    }

    public LicenseData a(String paramString1, String paramString2) {
        int i = paramString1.indexOf('-');
        if ((i > 0) && (paramString1.indexOf('-', i + 1) > 0)) {
            SubscriptionLicenseDataImpl localc = new SubscriptionLicenseDataImpl(paramString1, paramString2);
            localc.setFromUser(true);
            localc.setAccepted(false);
            return localc;
        }
        return new SubscriptionLicense(paramString1, paramString2, IdeaLicense.decoder);
    }
}
